package com.yhsoft.sys.controller;

import com.yhsoft.common.utils.WebSocket;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = {"A-websocket测试接口"})
@RequestMapping("/websocket")
public class WebSocketTestController {

    @GetMapping("/sendAllWebSocket")
    public String test() {
        String text="你们好！这是websocket群体发送！";
        WebSocket webSocket = new WebSocket();
        webSocket.sendAllMessage(text);
        return text;
    }

    @GetMapping("/sendOneWebSocket/{userId}")
    public String sendOneWebSocket(@PathVariable("userId") String userId) {
        String text= userId + " 你好！ 这是websocket单人发送！";
        WebSocket webSocket = new WebSocket();
        webSocket.sendOneMessage(userId,text);
        return text;
    }
}
